package com.xl.random;

import java.util.Random;
import java.util.Scanner;

public class RandomDemo2 {
    public static void main(String[] args) {
        //随机产生一个中奖号码
        Random random = new Random();
        int data = random.nextInt(10)+1;
        while (true) {
            System.out.println("请输入你的号码：");
            Scanner scanner = new Scanner(System.in);
            int number = scanner.nextInt();
            if (number == data) {
                System.out.println("恭喜你中奖了！");
                break;
            } else if (number > data){
                System.out.println("你的号码比中奖号码大！");
            } else {
                System.out.println("你的号码比中奖号码小！");
            }
        }
    }
}
